package com.gec.hawaste.controller;


import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.hawaste.entity.Statute;

import com.gec.hawaste.service.IStatuteService;
import com.gec.hawaste.utils.PageInfo;
import com.gec.hawaste.utils.ResultBean;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gec
 * @since 2022-07-01
 */
@RestController
@RequestMapping("/manager/statute")
public class StatuteController {
	
	@Autowired
	private IStatuteService iStatuteService;
	
	@RequestMapping("select/{current}/{size}")
	public ResultBean<IPage> select(@PathVariable("current")int current,
										@PathVariable("size") int size,
										@RequestParam Map<String,Object>params){
		PageInfo<Statute> pageInfo = new PageInfo<>(current, size);
				pageInfo=(PageInfo<Statute>) this.iStatuteService.selectBycc(pageInfo,params);
		
		//设置分页
		pageInfo.setNavigatePage();
		
		return ResultBean.ok(pageInfo);
		
	}
	//更新回显数据
	@RequestMapping("selectOne")
	public ResultBean<Statute>selectOne(int id){
		Statute statute = this.iStatuteService.getById(id);
		System.out.println("statute"+statute);
		return ResultBean.ok(statute);
	}
	
	//保存或者更新
	@RequestMapping("saveOrUpdate")
	public ResultBean SaveOrUpdate(@RequestBody Statute statute){
		this.iStatuteService.saveOrUpdate(statute);
		return ResultBean.ok();
	}
	
	//删除
	@RequestMapping("delete")
	public ResultBean delete(int id){
		this.iStatuteService.removeById(id);
		return ResultBean.ok();
		}
}
